package com.ddwl.wallet.dao;

import org.springframework.util.CollectionUtils;
import com.ddwl.common.dao.TkDao;
import com.ddwl.wallet.dao.mapper.UserWithdrawChannelMapper;
import com.ddwl.wallet.dao.model.UserWithdrawChannel;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 提现渠道
 */
@Repository
public class WithdrawChannelDao extends TkDao<UserWithdrawChannelMapper, UserWithdrawChannel> {


    public UserWithdrawChannel queryByUserIdAndAccount(String userId, String account){
        UserWithdrawChannel userWithdrawChannel = new UserWithdrawChannel();
        userWithdrawChannel.setUserId(userId);
        userWithdrawChannel.setAccount(account);
        userWithdrawChannel.setDflag(0);
        List<UserWithdrawChannel> channelList = baseMapper.select(userWithdrawChannel);
        if(!CollectionUtils.isEmpty(channelList)){
            return channelList.get(0);
        }
        return null;
    }

    public List<UserWithdrawChannel> queryUserChannel(String userId, List<Integer> codes) {
        Example example = getExample();
        example.and().andEqualTo("userId", userId)
                .andIn("type", codes);
        return baseMapper.selectByExample(example);
    }
}
